<%--
  Created by IntelliJ IDEA.
  User: wonderming
  Date: 2018/4/19
  Time: 14:51
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<div class="modal-header">
    <button class="close" ng-click="cancel()">
        <span aria-hidden="true">×</span>
    </button>
    <h3 class="modal-title" id="modal-title">风控限额管理</h3>
</div>

<div class="modal-body" id="modal-body">
    <div class="ibox-content no-borders tab-content">
        <!--添加-->
        <form name="myForm" class="form-horizontal formTopSpacing" ng-model="addrisklimit" ng-show="type == 0">
            <!-- 类型-->
            <div class="form-group">
                <label class="col-sm-3 control-label formTextVerticalMiddle"><span
                        class="text-danger">*</span>类型：</label>
                <div class="col-sm-8">
                    <select  name="type" class="form-control" ng-model="addrisklimit.refType"
                            ng-blur="typeBlur($event,addrisklimit.refType)" required>
                        <option value=""></option>
                        <option value="0">通用</option>
                        <option value="1">收单机构</option>
                        <option value="2">商户</option>
                        <option value="3">域名</option>
                    </select>
                </div>
            </div>
            <!-- 名称-->
            <div class="form-group" ng-show="addrisklimit.refType != '0' && addrisklimit.refType != '1' && addrisklimit.refType != '2' && addrisklimit.refType != '3'">
                <label class="col-sm-3 control-label formTextVerticalMiddle"><span
                        class="text-danger">*</span>名称：</label>
                <div class="col-sm-8">
                    <select name="name" class="form-control" ng-model="addrisklimit.refId"
                            ng-blur="nameBlur($event,addrisklimit.refId)" required>
                        <option  ng-value=""></option>
                    </select>
                </div>
            </div>
            <div class="form-group" ng-show="addrisklimit.refType == '0'">
                <label class="col-sm-3 control-label formTextVerticalMiddle"><span
                        class="text-danger">*</span>名称：</label>
                <div class="col-sm-8">
                    <select name="name" class="form-control" ng-model="addrisklimit.refId" ng-blur="nameBlur($event,addrisklimit.refId)" required>
                        <option ng-value="0">通用</option>
                    </select>
                </div>
            </div>
            <div class="form-group" ng-show="addrisklimit.refType == '1'">
                <label class="col-sm-3 control-label formTextVerticalMiddle"><span
                        class="text-danger">*</span>名称：</label>
                <div class="col-sm-8">
                    <select  name="name" class="form-control" ng-model="addrisklimit.refId"
                             ng-blur="nameBlur($event,addrisklimit.refId)" required>
                        <option  ng-repeat="x in init.acquirer" ng-value="x.id">
                            {{ x.name }}
                        </option>
                    </select>
                </div>
            </div>
            <div class="form-group" ng-show="addrisklimit.refType == '2'">
                <label class="col-sm-3 control-label formTextVerticalMiddle"><span
                        class="text-danger">*</span>名称：</label>
                <div class="col-sm-8">
                    <select name="name" class="form-control" ng-model="addrisklimit.refId"
                            ng-blur="nameBlur($event,addrisklimit.refId)" required>
                        <option  ng-repeat="x in init.merchant" ng-value="x.id">
                            ({{ x.id }}) {{ x.name }}
                        </option>
                    </select>
                </div>
            </div>
            <div class="form-group" ng-show="addrisklimit.refType == '3'">
                <label class="col-sm-3 control-label formTextVerticalMiddle"><span
                        class="text-danger">*</span>名称：</label>
                <div class="col-sm-8">
                    <select name="name" class="form-control" ng-model="addrisklimit.refId"
                            ng-blur="nameBlur($event,addrisklimit.refId)" required>
                        <option ng-repeat="x in init.siteurl" ng-value="x.id">
                            {{ x.siteUrl }}
                        </option>
                    </select>
                </div>
            </div>
            <!-- 限制类型-->
            <div class="form-group">
                <label class="col-sm-3 control-label formTextVerticalMiddle"><span
                        class="text-danger">*</span>限定类型:</label>
                <div class="col-sm-8">
                    <select  name="limitname" class="form-control" ng-model="addrisklimit.limitType"
                            ng-blur="limitnameBlur($event,addrisklimit.limitType)" required>
                        <option value=""></option>
                        <option value="0">笔</option>
                        <option value="1">日</option>
                        <option value="2">月</option>
                        <option value="3">年</option>
                    </select>
                </div>
            </div>
            <!-- 限制信用卡-->
            <div class="form-group">
                <label class="col-sm-3 control-label formTextVerticalMiddle">
                    <span class="text-danger">*</span>限定卡:
                </label>
                <div class="col-sm-8">
                    <select name="paytypename" class="form-control" ng-model="addrisklimit.payType" ng-options="x.id as x.firstValue for x in init.credit" ng-blur="paytypenameBlur($event,addrisklimit.payType)" required/>
                </div>
            </div>
            <!-- 限定币种-->
            <div class="form-group">
                <label class="col-sm-3 control-label formTextVerticalMiddle"><span
                        class="text-danger">*</span>限定币种：</label>
                <div class="col-sm-8">
                    <input type="text"  name="limitcurrency" class="form-control"
                           ng-model="addrisklimit.currency">
                </div>
            </div>
            <!-- 限定金额-->
            <div class="form-group">
                <label class="col-sm-3 control-label formTextVerticalMiddle"><span
                        class="text-danger">*</span>限定金额：</label>
                <div class="col-sm-8">
                    <input type="text" name="limitmoney" class="form-control" ng-model="addrisklimit.amount" ng-keyup="limitmoneyBlur($event,addrisklimit.amount)" required>
                </div>
            </div>
            <!-- 提醒值限定额的百分比-->
            <div class="form-group">
                <label class="col-sm-3 control-label formTextVerticalMiddle"><span
                        class="text-danger">*</span>提醒值限定额的百分比：</label>
                <div class="col-sm-8">
                    <input type="text" name="limitpercent" class="form-control" ng-model="addrisklimit.warning" ng-keyup="limitpercentBlur($event,addrisklimit.warning)" required>
                </div>
            </div>
            <!-- 状态-->
            <div class="form-group">
                <label class="col-sm-3 control-label formTextVerticalMiddle"><span
                        class="text-danger">*</span>状态:</label>
                <div class="col-sm-8">
                    <select name="limitstatus" class="form-control" ng-model="addrisklimit.status" ng-blur="limitstatusBlur($event,addrisklimit.status)" required>
                        <option value=""></option>
                        <option value="1">启用</option>
                        <option value="0">禁用</option>
                    </select>
                </div>
            </div>
        </form>
        <!-- 更新-->
        <form name="myFormUpdate" class="form-horizontal formTopSpacing" ng-model="risk" ng-show="type == 1">
            <!-- 类型-->
            <div class="form-group">
                <label class="col-sm-3 control-label formTextVerticalMiddle"><span
                        class="text-danger">*</span>类型：</label>
                <div class="col-sm-8">
                    <select  name="typeupdate" class="form-control" ng-model="risk.refType"
                            ng-blur="typeupdateFocus($event,risk.refType)" required>
                        <option value=""></option>
                        <option value="0">通用</option>
                        <option value="1">收单机构</option>
                        <option value="2">商户</option>
                        <option value="3">域名</option>
                    </select>
                </div>
            </div>
            <!-- 名称-->
            <div class="form-group">
                <label class="col-sm-3 control-label formTextVerticalMiddle"><span
                        class="text-danger">*</span>名称：</label>
                <div class="col-sm-8">
                    <select  name="nameupdate" class="form-control" ng-model="risk.refId"
                            ng-blur="nameupdateFocus($event,risk.refId)" required>
                        <option ng-repeat="x in initParam" value="{{ x.id }}">
                            {{ x.name != undefined ? x.name : x.siteUrl }}
                        </option>
                    </select>
                </div>
            </div>
            <!-- 限制类型-->
            <div class="form-group">
                <label class="col-sm-3 control-label formTextVerticalMiddle"><span
                        class="text-danger">*</span>限定类型:</label>
                <div class="col-sm-8">
                    <select name="limitnameupdate" class="form-control" ng-model="risk.limitType"
                            ng-blur="limitnameupdateFocus($event,risk.limitType)" required>
                        <option value=""></option>
                        <option value="0">笔</option>
                        <option value="1">日</option>
                        <option value="2">月</option>
                        <option value="3">年</option>
                    </select>
                </div>
            </div>
            <!-- 限制卡-->
            <div class="form-group">
                <label class="col-sm-3 control-label formTextVerticalMiddle">
                    <span class="text-danger">*</span>限定卡:
                </label>
                <div class="col-sm-8">
                    <select name="paytypenameupdate" class="form-control" ng-model="risk.payType" ng-options="x.id as x.firstValue for x in init.credit" ng-blur="paytypenameupdateFocus($event,risk.payType)" required/>
                </div>
            </div>
            <!-- 限定币种-->
            <div class="form-group">
                <label class="col-sm-3 control-label formTextVerticalMiddle"><span
                        class="text-danger">*</span>限定币种：</label>
                <div class="col-sm-8">
                    <input type="text" name="limitcurrencyupdate" class="form-control" ng-model="risk.currency"  readonly>
                </div>
            </div>
            <!-- 限定金额-->
            <div class="form-group">
                <label class="col-sm-3 control-label formTextVerticalMiddle"><span
                        class="text-danger">*</span>限定金额：</label>
                <div class="col-sm-8">
                    <input type="text" name="limitmoneyupdate" class="form-control" ng-model="risk.amount" ng-keyup="limitmoneyupdateBlur($event,risk.amount)" required>
                </div>
            </div>
            <!-- 提醒值限定额的百分比-->
            <div class="form-group">
                <label class="col-sm-3 control-label formTextVerticalMiddle"><span
                        class="text-danger">*</span>提醒值限定额的百分比：</label>
                <div class="col-sm-8">
                    <input type="text" name="limitpercentupdate" class="form-control"  ng-model="risk.warning" ng-keyup="limitpercentupdateBlur($event,risk.warning)" required>
                </div>
            </div>
            <!-- 状态-->
            <div class="form-group">
                <label class="col-sm-3 control-label formTextVerticalMiddle"><span
                        class="text-danger">*</span>状态:</label>
                <div class="col-sm-8">
                    <select name="statusupdate" class="form-control" ng-model="risk.status" ng-blur="statusupdateBlur($event,risk.status)" required>
                        <option value=""></option>
                        <option value="1">启用</option>
                        <option value="0">禁用</option>
                    </select>
                </div>
            </div>
        </form>
    </div>
</div>

<div class="modal-footer">
    <row>
        <div class="col-sm-12">
            <div class="center">
                <button class="btn btn-sm btn-primary general-btn" type="button"
                        ng-click="insertRiskQuota(addrisklimit,0)"
                        ng-disabled="!myForm.type.$valid || !myForm.name.$valid || !myForm.limitname.$valid || !myForm.limitstatus.$valid || !myForm.limitmoney.$valid || !myForm.limitpercent.$valid || !myForm.paytypename"
                        ng-show="type == 0">
                    确定
                </button>
                <button class="btn btn-sm btn-primary general-btn" type="button" ng-click="updateRiskQuota(risk,1)"
                        ng-disabled="nextDisabled(myFormUpdate)"
                        ng-show="type == 1">
                    确定
                </button>
            </div>
        </div>
    </row>
</div>

